﻿@using Zj.CourseManage.DTO.Common
@using Zj.CourseManage.DTO.Common.Pagination
@model  PaginatedList<DepartmentDTO>
@{
    ViewData["Title"] = "学院列表";
}
<h2>@ViewData["Title"]</h2>
<a asp-action="Create" class="text-success">添加学院</a>
<hr />
<form class="form-inline" role="form" method="get" action="/Departments/Index">
    <div class="form-group">
        <label class="sr-only" for="searchString">@Html.DisplayNameFor(x => Model.FirstOrDefault().Name)</label>
        <input type="text" class="form-control" name="searchString" id="searchString" placeholder="@Html.DisplayNameFor(x => Model.FirstOrDefault().Name)">
    </div>
    <button type="submit" class="btn btn-default">Submit</button>
    <a asp-action="index">显示所有</a>
</form>
<hr />
<table class="table table-bordered table-striped table-condensed">
    <tr>
        <th>
            <a asp-route-sortName="@ViewData["sortField"]" asp-route-searchString="@ViewData["searchString"]">@Html.DisplayNameFor(x => Model.FirstOrDefault().Id)</a>
        </th>
        <th>
            <a asp-route-sortName="@ViewData["sortField"]" asp-route-searchString="@ViewData["searchString"]">@Html.DisplayNameFor(x => Model.FirstOrDefault().Name)</a>
        </th>
        <th>@Html.DisplayNameFor(x => Model.FirstOrDefault().Budget)</th>
        <th>操作</th>
    </tr>
    @foreach (var item in Model)
    {
        <tr>
            <td>@Html.DisplayFor(x => item.Id)</td>
            <td>@Html.DisplayFor(x => item.Name)</td>
            <td>@Html.DisplayFor(x => item.Budget)</td>
            <th>
                <div class="btn-group" role="group" aria-label="...">
                    @*<button type="button" asp-action="edit" asp-route-id="@item.Id" class="btn btn-primary">修改</button>*@
                    @*<button type="button" asp-action="Delete" asp-route-id="@item.Id" class="btn btn-danger">删除</button>*@
                    <a asp-action="Edit" asp-route-id="@item.Id" class="text-primary">修改</a>
                    <a asp-action="Delete" asp-route-id="@item.Id" class="text-danger">删除</a>
                </div>
            </th>
        </tr>
    }
</table>
@{ 
    var previousDisable = Model.HasPrevious?"":"disabled";
    var nextDisable = Model.HasNext ? "" : "disabled";
    var previous = (int)ViewData["pageIndex"] - 1;
    var next = (int)ViewData["pageIndex"] + 1;
}
<nav aria-label="...">
    <ul class="pager">
        <li><a asp-action="Index" asp-route-searchString="@ViewData["searchString"]" asp-route-pageIndex="@previous" class="btn @previousDisable">Previous</a></li>
        <li><a asp-action="Index" asp-route-searchString="@ViewData["searchString"]" asp-route-pageIndex="@next" class="btn @nextDisable">Next</a></li>
    </ul>
</nav>
